package net.sk.china.city.talk.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sk.china.city.talk.request.user.AdminIntegralSearchRequest;
import net.sk.china.city.talk.response.user.UserIntegralRecordResponse;
import net.sk.china.city.talk.service.user.UserIntegralRecordService;
import net.sk.china.common.request.PageParamRequest;
import net.sk.china.common.response.CommonPage;
import net.sk.china.common.response.CommonResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * +----------------------------------------------------------------------
 * | Talk To [ 聊来改善地区金融服务环境，助力企业发展 ]
 * +----------------------------------------------------------------------
 * | Copyright (c) 2018-2024 聊来All rights reserved.
 * +----------------------------------------------------------------------
 * | Licensed ( <a href="http://www.apache.org/licenses/LICENSE-2.0">apache</a> )
 * +----------------------------------------------------------------------
 * | @Author: 聊来 <18970881148@qq.com>
 * +----------------------------------------------------------------------
 * | DateTime: 2024/6/2 21:55
 * +----------------------------------------------------------------------
 */

@RestController
@RequestMapping("user/integral/")
@Api(tags = "用户积分管理")
public class UserIntegralController {

    private final UserIntegralRecordService integralRecordService;

    public UserIntegralController(UserIntegralRecordService integralRecordService) {
        this.integralRecordService = integralRecordService;
    }

    @PreAuthorize("hasAuthority('admin:user:integral:list')")
    @ApiOperation(value = "列表")
    @RequestMapping(value = "list", method = RequestMethod.POST)
    public CommonResult<CommonPage<UserIntegralRecordResponse>> getList(@RequestBody @Validated AdminIntegralSearchRequest request, @Validated PageParamRequest pageParamRequest) {
        CommonPage<UserIntegralRecordResponse> restPage = CommonPage.restPage(integralRecordService.findAdminList(request, pageParamRequest));
        return CommonResult.success(restPage);
    }
}
